#include "zigbeeserialportcontrolsimulator.h"

ZigBeeSerialPortControlSimulator::ZigBeeSerialPortControlSimulator(QObject *parent) :
    QObject(parent),
    m_qstrFileName(""),
    m_bOpen(false),
    m_currentWorkMode(ZIGBEE)
{
}


void ZigBeeSerialPortControlSimulator::slt_setDevOnOrOff(const QString &fileName, bool onOff)
{

    m_bOpen = onOff;
    if (m_bOpen)
    {
        emit sig_realTimeInfo(trUtf8("ZigBee-->网络接入串口打开成功！"));
        m_qstrFileName = fileName;
        emit sig_SerialPortInfo(m_qstrFileName, m_bOpen);
        emit sig_open();
    } else
    {
        emit sig_realTimeInfo(trUtf8("ZigBee-->网络接入串口关闭成功！"));
        emit sig_SerialPortInfo(m_qstrFileName, m_bOpen);
        m_qstrFileName = "";
        emit sig_close();
    }


}

void ZigBeeSerialPortControlSimulator::slt_SerialPortInfo(const QString &fileName)
{
    if (m_qstrFileName == fileName)
    {
        emit sig_SerialPortInfo(m_qstrFileName, m_bOpen);
    } else {
        emit sig_SerialPortInfo(fileName, false);
    }
}
